<?php
/**
 * Created by PhpStorm.
 * User: gc
 * Date: 2017/8/28
 * Time: 23:31
 *///解析当前路径，自动载入目录
$dir_str=__DIR__;
$web_dir=mb_strcut($dir_str,0,strripos($dir_str,DIRECTORY_SEPARATOR));
define('D',$web_dir);
define('DS',DIRECTORY_SEPARATOR);
echo D;

class init{
    public static function floader($class_name)
    {

        $class_name=strtr($class_name,"\\",DS);
        $file_path=D.DS."app".DS.$class_name.'.php';
        is_file($file_path) or self::nofile($class_name);
        require($file_path);
    }

    public static function run()
    {
        (isset($_GET['_c']) and trim($_GET['_c'])!='') or $_GET['_c']="index";
        (isset($_GET['_m']) and trim($_GET['_m'])!='') or $_GET['_m']="index";
        $_GET["_c"]=strtr($_GET['_c'],['\\'=>'','/'=>'','.'=>'']);
        $_GET["_m"]=strtr($_GET['_m'],['\\'=>'','/'=>'','.'=>'']);
        $file_path=D.DS."app".DS."c".DS.$_GET["_c"].".php";
        is_file($file_path) or self::nofile($_GET['_c']);
        require($file_path);
        $c="\\c\\".$_GET["_c"];
        $m=$_GET['_m'];
        $o=new $c();
        $o->$m();
    }

    public static function nofile($str)
    {
        exit('nofile:'.$str);
    }
}
//解析当前路径，自动载入目录
spl_autoload_register("\\init::floader");//注册自动类库的方法。

$f=new \init();
$f->run();
